package com.shilan.administrator.qintfm.volley;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dllo on 15/10/22.
 */
public class GetVolleyDatasUtil {

    private static VolleySingleton volleySingleton = VolleySingleton.getInstance();


    public static void getBitmapRequest(String url,final ImageView imageView){

        ImageRequest request = new ImageRequest(url,
                new Response.Listener<Bitmap>() {
                    @Override
                    public void onResponse(Bitmap response) {

                        //将返回的图片对象设置到图片组件中
                        imageView.setImageBitmap(response);
                    }
                }, 720, 200, Bitmap.Config.ARGB_8888,
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        error.printStackTrace();
                    }
                }){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                // TODO Auto-generated method stub
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("Accept-Encoding", "");
                return map;
            }
        };

        volleySingleton.addRequest(request);
    };





}
